

import java.util.ArrayList;

import logic.MySQLconnection;
import Entities.RequestEntity;
import fit.ActionFixture;
import gui.AcademicFrame;
import gui.ServerGui;

public class ManageRequest   extends ActionFixture
{
	ServerGui server;
	AcademicFrame client;
	
	String reqID;
	String currentS;
	String change;
	String explanation;
	String supervisorID;
	
	public void setupfixture()
	{
		server = new ServerGui();
		server.fakeServer(5555, "mysql://localhost/test", "root", "Braude");
		server.myLog.setVisible(false);
		client = new AcademicFrame("Localhost",5555);
		
	}
	
	public void setRequestID (String requestID)
	{
		reqID = requestID;
	}
	public void setCurrentS (String current)
	{
		currentS = current;
	}
	public void setChange (String changeI)
	{
		change = changeI;
	}
	public void setExplanation (String explanationI)
	{
		explanation = explanationI;
	}
	public void setSupervisorID (String supervisorIDI)
	{
		supervisorID = supervisorIDI;
	}
	
	  
	public boolean manageRequest()
	{
		
		ArrayList<Object> question = new ArrayList<Object>();
		ArrayList<Object> answer = new ArrayList<Object>();
		
		question.add("updateFields");
		question.add(reqID);
		question.add(currentS);
		question.add(change);
		question.add(explanation);
		question.add(supervisorID);
		client.myclient.sendMessageToServer(question);
		while (client.answer==null);
		answer = client.answer;
		client.answer=null;
		
		
		if(answer.get(0).equals("success"))
			return true;
		else
			return false;
	}
}
